<div id="page-wrapper">

    <div class="container-fluid">

        <!-- Page Heading -->
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">
                    Product <small>Manage product Page</small>
                </h1>
            </div>
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Product Detail</h3>
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <label>Product Name</label>
                            <input class="form-control">
                            <p class="help-block">Example: Edelweiss Cheese ... etc</p>
                        </div>
                        <div class="col-lg-6">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <div class="pull-right">
                                        <input type="button" id="uploadfile" class="btn btn-xs btn-primary" value="Upload"/>
                                    </div>
                                    <h4 class="panel-title">Product File Attach</h4>                                   
                                </div>
                                <div class="panel-body">
                                    <div class="list-group" id="file_menu_list">            

                                    </div>
                                </div>
                            </div>
                        </div> 
                        <div class="col-lg-6">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <div class="pull-right">
                                        <input type="button" class="btn btn-xs btn-primary" value="Upload"/>
                                    </div>
                                    <h3 class="panel-title">Product Image Attach</h3>
                                </div>
                                <div class="panel-body">
                                    <div class="list-group" id="main_menu_list">            
                                        <a href="#" class="list-group-item">                                            
                                            <span class="badge"><i class= "fa fa-trash"></i></span>
                                            <span><i class="fa fa-fw fa-calendar"></i> Home</span>
                                        </a>                                        
                                    </div>
                                </div>
                            </div>
                        </div> 
                    </div>
                </div>
            </div>      
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Product Description</h3>
                    </div>
                    <div class="panel-body">
                        <textarea class="summernote" name="product_description" id="product_description"></textarea>
                    </div>
                </div>
            </div>
            <button type="button" class="btn btn-default">Submit</button>
            <button type="button" onclick="closeMainDialog()" class="btn btn-default">Cancel</button>
        </div>
        <!-- /.row -->
    </div>
    <!-- /.container-fluid -->
    <div id="dialog_upload_file" title="Upload File to server...">
        <div>
            <ul class="list-group">
                <li href="#" class="list-group-item active">
                    File Upload
                    <div class="pull-right">
                        <input type="button" class="btn btn-xs btn-primary close_file_upload_dialog" value="Close"/>
                    </div>
                </li>
                <li class = "list-group-item">
                    <div class="mulitplefileuploaderFile">Upload</div>
                    <div id="status"></div>
                </li>
            </ul>
        </div>
        <div id="edit_image"></div>
    </div>
    <div id="dialog_show_link" title="Get Link">
        <span id="show_link_span"></span>
    </div>
</div>
<style type="text/css">
    .ui-dialog-titlebar-close {
        visibility: hidden;
    }
</style>
<!-- Bootstrap Core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom CSS -->
<link href="assets/css/sb-admin.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/jquery-ui.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/plugins/summernote/summernote.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="assets/css/uploadfile.css" media="screen" />
<!-- jQuery -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="assets/js/jquery.uploadfile.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/plugins/summernote/summernote.js"></script>
<script src="assets/js/jquery.blockUI.js"></script>
<script src="assets/js/SwissMoohScript.js"></script>            
<script type="text/javascript">
                var settings;
                var uploadFileDialog = $("#dialog_upload_file").dialog({
                    closeOnEscape: true,
                    autoOpen: false,
                    height: 400,
                    width: 500,
                    modal: true

                });
                $(document).ready(function () {
                    settings = {
                        url: "model/com.swiss.mooh.controller/upload_file_attach.php",
                        dragDrop: true,
                        fileName: "myfile",
                        allowedTypes: "doc,pdf,zip,xls,xlsx",
                        returnType: "json",
                        onSuccess: function (files, data, xhr)
                        {
                            //alert("Upload file: " + data + " complete !!");
                        },
                        showDelete: true,
                        deleteCallback: function (data, pd)
                        {
                            for (var i = 0; i < data.length; i++)
                            {
                                $.post("model/com.swiss.mooh.controller/delete_file_attach.php", {op: "delete", name: data[i]},
                                function (resp, textStatus, jqXHR)
                                {
                                    //alert(resp);
                                });
                            }
                            pd.statusbar.hide(); //You choice to hide/not.

                        }
                    };
                    var uploadObj = $(".mulitplefileuploaderFile").uploadFile(settings);
                    var uiSummernote = function () {
                        /* Extended summernote editor */
                        if ($(".summernote").length > 0) {
                            $(".summernote").summernote({
                                height: 300,
                                codemirror: {
                                    mode: 'text/html',
                                    htmlMode: true,
                                    lineNumbers: true,
                                    theme: 'default'
                                }
                            });
                        }
                    };
                    uiSummernote();
                    $("#uploadfile").click(function () {
                        uploadFileDialog.dialog("open");
                    });
                    $(".close_file_upload_dialog").click(function () {
                        $.ajax({
                            url: "model/com.swiss.mooh.controller/GetNullFileContent.php",
                            type: 'POST',
                            success: function (data, textStatus, jqXHR) {
                                $("#file_menu_list").html(data);
                                uploadFileDialog.dialog("close");
                            }
                        });
                    });
                });
                function deleteFileByName(fileName) {
                    $.ajax({
                        url: "model/com.swiss.mooh.controller/DeleteFileByName.php",
                        type: 'POST',
                        data: {'fileName': fileName},
                        success: function (data, textStatus, jqXHR) {
                            $("#file_menu_list").html(data);
                        }
                    });
                }
                function getLink(path) {
                    $("#dialog_show_link").dialog();
                    $("#show_link_span").html(path);
                }
</script>